﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;

namespace BHair.Base
{
    public partial class frmdangan : Form
    {
        public frmdangan()
        {
            InitializeComponent();
        }
        string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
        private void frmdangan_Load(object sender, EventArgs e)
        {
            label5.Text = chuanzhi.tlcard;
            label7.Text = chuanzhi.tlname;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT [id] ,[卡号] ,[颈椎病] ,[肩周炎] ,[风湿] ,[腰肌劳损] ,[腰间盘] ,[关节炎] ,[养肾护肾] ,[高低血压] ,[失眠] ,[内分泌失调] ,[色斑] ,[痤疮],[更年期综合征] ,[痛经] ,[阴道炎] ,[附件炎] ,[盆腔炎] ,[盆腔积液] ,[宫颈炎] ,[宫颈糜烂] ,[其他妇科炎症] ,[其他] FROM [tljb] where 卡号='{0}'",chuanzhi.tlcard);
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            while (sdr.Read())

            {
                if (sdr["颈椎病"].ToString() == "1")
                {
                    cbjzb.Checked = true;
                }
                if (sdr["肩周炎"].ToString() == "1")
                {
                    cbjzy.Checked = true;
                }
                if (sdr["风湿"].ToString() == "1")
                {
                    cbfs.Checked = true;
                }
                if (sdr["腰肌劳损"].ToString() == "1") { cbyjls.Checked = true; }
                if (sdr["腰间盘"].ToString() == "1") { cbyjp.Checked = true; }
                if (sdr["关节炎"].ToString() == "1") { cbgjy.Checked = true; }
                if (sdr["养肾护肾"].ToString() == "1") { cbyshs.Checked = true; }
                if (sdr["高低血压"].ToString() == "1") { cbgdxy.Checked = true; }
                if (sdr["失眠"].ToString() == "1") { cbsm.Checked = true; }
                if (sdr["内分泌失调"].ToString() == "1") { cbnfmst.Checked = true; }
                if (sdr["色斑"].ToString() == "1") { cbsb.Checked = true; }
                if (sdr["痤疮"].ToString() == "1") { cbcc.Checked = true; }
                if (sdr["更年期综合征"].ToString() == "1") { cbgnq.Checked = true; }
                if (sdr["痛经"].ToString() == "1") { cbtj.Checked = true; }
                if (sdr["阴道炎"].ToString() == "1") {cbydy.Checked = true; }
                if (sdr["附件炎"].ToString() == "1") { cbfjy.Checked = true; }
                if (sdr["盆腔炎"].ToString() == "1") { cbpqy.Checked = true; }
                if (sdr["盆腔积液"].ToString() == "1") { cbpqjy.Checked = true; }
                if (sdr["宫颈炎"].ToString() == "1") { cbgongjy.Checked = true; }
                if (sdr["宫颈糜烂"].ToString() == "1") { cbgjml.Checked = true; }
                if (sdr["其他妇科炎症"].ToString() == "1") { cbqt.Checked = true; }
                textBox1.Text = sdr["其他"].ToString();










            }
            conn.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int jzb = 0;
            if (cbjzb.Checked==true)
            {
                jzb = 1;
            }
            int jzy = 0;
            if (cbjzy.Checked == true)
            {
                jzy = 1;
            }
            int fs = 0;
            if (cbfs.Checked == true)
            {
                fs = 1;
            }
            int yjls = 0;
            if (cbyjls.Checked == true)
            {
                yjls = 1;
            }
            int yjp = 0;
            if (cbyjp.Checked == true)
            {
                yjp = 1;
            }
            int gjy = 0;
            if (cbgjy.Checked == true)
            {
                gjy = 1;
            }
            int yshs = 0;
            if (cbyshs.Checked == true)
            {
                yshs = 1;
            }
            int gdxy = 0;
            if (cbgdxy.Checked == true)
            {
                gdxy = 1;
            }
            int sm = 0;
            if (cbsm.Checked==true)
            {
                sm = 1;
            }
            int nfmst = 0;
            if (cbnfmst.Checked == true)
            {
                nfmst = 1;
            }
            int sb = 0;
            if (cbsb.Checked==true) { sb = 1; }
            int cc = 0;
            if (cbcc.Checked == true) { cc = 1; }
            int gnq = 0;
            if (cbgnq.Checked == true) { gnq = 1; }
            int tj = 0;
            if (cbtj.Checked == true) { tj = 1; }
            int ydy = 0;
            if (cbydy.Checked == true) { ydy = 1; }
            int fjy = 0;
            if (cbfjy.Checked == true) { fjy = 1; }
            int pqy = 0;
            if (cbpqy.Checked == true) { pqy = 1; }
            int pqjy = 0;
            if (cbpqjy.Checked == true) { pqjy = 1; }
            int gongjy = 0;
            if (cbgongjy.Checked == true) { gongjy = 1; }
            int gjml = 0;
            if (cbgjml.Checked == true)
            {
                gjml = 1;
            }
            int qtfkyz = 0;
            if (cbqt.Checked == true)
            {
                qtfkyz = 1;
            }

            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "UPDATE [tljb] SET [卡号] = '{0}'  ,[颈椎病] = {1}  ,[肩周炎] = {2} ,[风湿] = {3}  ,[腰肌劳损] = {4} ,[腰间盘] = {5} ,[关节炎] = {6} ,[养肾护肾] = {7} ,[高低血压] = {8} ,[失眠] = {9},[内分泌失调] = {10},[色斑] = {11}  ,[痤疮] = {12},[更年期综合征] ={13},[痛经] = {14} ,[阴道炎] = {15} ,[附件炎] = {16} ,[盆腔炎] = {17} ,[盆腔积液] = {18} ,[宫颈炎] = {19} ,[宫颈糜烂] = {20} ,[其他妇科炎症] = {21} ,[其他] = '{22}' WHERE 卡号='{23}'",label5.Text,jzb,jzy,fs,yjls,yjp,gjy,yshs,gdxy,sm,nfmst,sb,cc,gnq,tj,ydy,fjy,pqy,pqjy,gongjy,gjml,qtfkyz,textBox1.Text,label5.Text);
            SqlCommand comm = new SqlCommand(sql,conn);
            comm.ExecuteNonQuery();
            conn.Close();
            MessageBox.Show("ok");

        }
    }
}
